#! /usr/local/bin/ruby

# This code may not be needed??
# Currently (Oct. 2007) only used in one test. 

# In fact the contents need not be text.
# For our purposes they usually will be.
# Contains pairs of Strings, one for content and one for path
class TextFile
  include Comparable

  attr_reader :contents, :path

  def initialize(contents, path)
    @contents = contents
    @path = path
  end


  # Files with equal contents should sort so that they're next to one another.

  # Beyond that we don't much care but we want a deterministic sort order for

  # the benefit of our tests.
  def <=>(other)
    comp = (contents <=> other.contents)

    if comp == 0
      return path <=> other.path
    else
      return comp
    end
  end

  def equal_contents(other)
    return contents == other.contents
  end

end

